package com.beifu.manager.controller;

import java.util.List;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.beifu.manager.model.Tree;
import com.beifu.manager.shiro.ActiveUser;

@Controller
public class IndexController {

	/*@Autowired
	private MenuService menuService;*/

	/**
	 * 跳转首页
	 * @param model
	 * @return
	 */
	@RequestMapping("/index")
	public String index(Model model){
		Subject subject = SecurityUtils.getSubject();
		ActiveUser activeUser = (ActiveUser)subject.getPrincipal();

		List<Tree> menus = activeUser.getMenus();
		model.addAttribute("menus", menus);
		model.addAttribute("userName", activeUser.getUserName());

		return "index";
	}

	@RequestMapping("/index/goUpdatePassPage")
	public String goUpdatePassPage(Model model){
		return "/index/updatePass";
	}

	@RequestMapping("/index/gopersonalDataPage")
	public String gopersonalDataPage(Model model){
		return "/index/personalData";
	}

	/*@ResponseBody
	@RequestMapping("/index/unlock")
	public String Unlock(Model model,HttpServletRequest request){
		String pass = request.getParameter("pass");
		String ps = ShiroSecurityHelper.encryptedPass(pass);
		User user = ShiroSecurityHelper.getCurrentUser();
		if (!user.getPassword().equals(ps)) {
			return ResponseHelp.responseErrorText("密码错误");
		}
		return ResponseHelp.responseText();
	}*/
}
